package com.ruoyi.interfaced.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.interfaced.domain.ShopAddressInter;
import com.ruoyi.interfaced.service.IShopAddressInterService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地址Controller
 * 
 * @author ruoyi
 * @date 2021-12-07
 */
@RestController
@RequestMapping("/interfaced/address")
public class ShopAddressInterController extends BaseController
{
    @Autowired
    private IShopAddressInterService shopAddressService;

    /**
     * 添加
     */

    @GetMapping("add")
    public String insert(ShopAddressInter shopAddress, Model model){
        int a = shopAddressService.insert(shopAddress);
//        System.out.println(shopAddress);
        model.addAttribute(a);
        return "";
    }

    /**
     * 地址修改
     */

    @GetMapping("edit")
    public String update(ShopAddressInter shopAddress, Model model){
        int a = shopAddressService.update(shopAddress);
//        System.out.println(shopAddress);
        model.addAttribute(a);
        return "";
    }

    @GetMapping("delete")
    public String delete(ShopAddressInter shopAddress, Model model){
        int a = shopAddressService.delete(shopAddress);
        System.out.println(shopAddress);
        model.addAttribute(a);
        return "";
    }

    /**
     * 查询地址列表
     */
//    @PreAuthorize("@ss.hasPermi('order:address:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopAddressInter shopAddress)
    {
        startPage();
        List<ShopAddressInter> list = shopAddressService.selectShopAddressList(shopAddress);
        return getDataTable(list);
    }
//
//    /**
//     * 导出地址列表
//     */
//    @PreAuthorize("@ss.hasPermi('order:address:export')")
//    @Log(title = "地址", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ShopAddress shopAddress)
//    {
//        List<ShopAddress> list = shopAddressService.selectShopAddressList(shopAddress);
//        ExcelUtil<ShopAddress> util = new ExcelUtil<ShopAddress>(ShopAddress.class);
//        util.exportExcel(response, list, "地址数据");
//    }
//
//    /**
//     * 获取地址详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('order:address:query')")
//    @GetMapping(value = "/{shopId}")
//    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
//    {
//        return AjaxResult.success(shopAddressService.selectShopAddressByShopId(shopId));
//    }
//
//    /**
//     * 新增地址
//     */
//    @PreAuthorize("@ss.hasPermi('order:address:add')")
//    @Log(title = "地址", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody ShopAddress shopAddress)
//    {
//        return toAjax(shopAddressService.insertShopAddress(shopAddress));
//    }
//
//    /**
//     * 修改地址
//     */
//    @PreAuthorize("@ss.hasPermi('order:address:edit')")
//    @Log(title = "地址", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody ShopAddress shopAddress)
//    {
//        return toAjax(shopAddressService.updateShopAddress(shopAddress));
//    }
//
//    /**
//     * 删除地址
//     */
//    @PreAuthorize("@ss.hasPermi('order:address:remove')")
//    @Log(title = "地址", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{shopIds}")
//    public AjaxResult remove(@PathVariable Long[] shopIds)
//    {
//        return toAjax(shopAddressService.deleteShopAddressByShopIds(shopIds));
//    }
}
